package com.basic.modules.nykf.controller;

import com.basic.common.utils.PageUtils;
import com.basic.common.utils.ParamsModel;
import com.basic.common.utils.R;
import com.basic.modules.nykf.entity.JxGsEntity;
import com.basic.modules.nykf.entity.JxKfEntity;
import com.basic.modules.nykf.entity.JxSjEntity;
import com.basic.modules.nykf.service.JxGsService;
import com.basic.modules.nykf.service.JxKfService;
import com.basic.modules.nykf.service.JxSjService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 绩效相关
 */
@RestController
@RequestMapping("new/ykf/performance")
public class PerformanceController {

    @Autowired
    JxKfService jxKfService;

    @Autowired
    JxGsService jxGsService;

    @Autowired
    JxSjService jxSjService;

    /**
     * 获取客服绩效
     *
     * @param params
     * @return
     */
    @PostMapping("/getKfJxList")
    public R getKfJxList(@RequestBody ParamsModel<JxKfEntity> params) {
        System.out.println(params);
        JxKfEntity jxKfEntity = params.getCondition();
        List<JxKfEntity> kfJxList = new ArrayList<>();
        if
        (
                jxKfEntity.getYf() == null || "".equals(jxKfEntity.getYf())
        ) {

        } else {
            kfJxList = jxKfService.getKfJxList(jxKfEntity);
        }
        Map map1 = new HashMap();
        map1.put("totalCount", kfJxList.size());
        map1.put("list", kfJxList);
        return R.ok(map1);
    }

    /**
     * 获取公司绩效
     *
     * @param params
     * @return
     */
    @PostMapping("/getGsJxList")
    public R getGsJxList(@RequestBody ParamsModel<JxGsEntity> params) {
        System.out.println(params);
        JxGsEntity jxGsEntity = params.getCondition();
        List<JxGsEntity> gsJxList = new ArrayList<>();
        if
        (
                jxGsEntity.getYf() == null || "".equals(jxGsEntity.getYf())
        ) {

        } else {
            gsJxList = jxGsService.getGsJxList(jxGsEntity);
        }
        Map map1 = new HashMap();
        map1.put("totalCount", gsJxList.size());
        map1.put("list", gsJxList);
        return R.ok(map1);
    }

    /**
     * 待录入子账号查询
     *
     * @return
     */
    @PostMapping("/getDlrZzhList")
    public R getDlrZzhList(@RequestBody ParamsModel<JxSjEntity> params) {
        JxSjEntity jxSjEntity = params.getCondition();
        if (jxSjEntity.getDate() == null) {
            return R.ok();
        } else {
            PageUtils page = jxSjService.getDlrZzhList(params);
            return R.ok(page);
        }
    }

    @PostMapping("/postSjlr")
    public R postSjlr(@RequestBody JxSjEntity jxSjEntity) {
        return jxSjService.postSjlr(jxSjEntity);
    }
}